import sys
from flask import Flask
from flask_restful import Api
from src.routers.hello import Hello
from src.routers.hellosec import HelloSec
from src.routers.BuildESRITpkRouter import BuildESRITpkRouter
from src.routers.BuildESRISlpkRouter import BuildESRISlpkRoute
from src.routers.BuildTMSRouter import BuildTMSRouter
from src.routers.BuildC3DTRouter import BuildC3DTRouter
from src.routers.BuildWMTSRouter import BuildWMTSRouter
from src.routers.BuildMapboxTileServerRouter import BuildMapboxTileServerRouter
from src.routers.BuildESRIBundleRouter import BuildESRIBundleRouter
from src.routers.ESRISlpk.esri_slpk_tile import Zip
from src.routers.services_manager import GetServicesList
from src import SysConfig

sys.path.append("../..")

# 读取配置文件
globalConfig = SysConfig.sys_config

app = Flask(__name__)
api = Api(app)

'''***************************注册路由***************************'''
# 用于测试的路由
api.add_resource(Hello, '/')
api.add_resource(HelloSec, '/HelloSec')
# 注册各种类型服务路由
BuildESRITpkRouter(api)
BuildESRISlpkRoute(api)
BuildTMSRouter(api)
BuildC3DTRouter(api)
BuildWMTSRouter(api)
BuildMapboxTileServerRouter(api)
BuildESRIBundleRouter(api)
# 针对zip压缩包的万能路由
api.add_resource(Zip, '/<string:servicename>/zip/<path:full_path>')
# 服务列表
api.add_resource(GetServicesList, '/services/list')
'''***************************注册路由***************************'''

# 打印调试模式
print(globalConfig['debug'])

# 程序入口
def startServer():
    app.run(host=globalConfig['host'], debug=globalConfig['debug'], port=globalConfig['port'])

